<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-gatewayConfig-add">
        <div class="form-group">
            <label class="col-sm-3 control-label">路由url：</label>
            <div class="col-sm-8">
                <input id="url" name="url" class="form-control" type="text">
                <span class="help-block m-b-none">
                    <i class="fa fa-info-circle"></i>注意：lb://表示以注册中心进行转发，url为注册服务名称(需要大写) 例如:lb://ORDER-SERVICE；
                    <br>http://或http://表示以固定url转发</span>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">路由后缀Path，紧跟url：</label>
            <div class="col-sm-8">
                <input id="suffixPath" name="suffixPath" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">状态：</label>
            <div class="col-sm-8">
                <div class="onoffswitch">
                    <input type="checkbox" th:checked="true" class="onoffswitch-checkbox" id="gateway-state">
                    <label class="onoffswitch-label" for="gateway-state">
                        <span class="onoffswitch-inner"></span>
                        <span class="onoffswitch-switch"></span>
                    </label>
                </div>
            </div>
        </div>
    </form>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript">
    var prefix = ctx + "system/gatewayConfig"
    $("#form-gatewayConfig-add").validate({
        rules: {
            xxxx: {
                required: true,
            },
        },
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            var data = $('#form-gatewayConfig-add').serializeArray();
            var state = $("input[id='gateway-state']").is(':checked') == true ? 1 : 0;
            data.push({"name": "state", "value": state});
            $.operate.save(prefix + "/add", serialize);
        }
    }
</script>
</body>
</html>
